console.log("我要学习javascript");

var arr = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];

var arr2 = ['Microsoft', 'Apple', 'Yahoo', 'AOL', 'Excite', 'Oracle'];

//join
console.log(arr.join('-'));

//concat
var arr3 = ['A', 'B', 'C'];
var added=[1,2];
console.log(arr3.concat(added));
console.log(arr3); //并没有修改arr3


//splice
console.log(arr2.splice(2,3,'google','alibaba')); //删除 添加
console.log(arr2);
console.log(arr2.splice(2,2)); //只删除
console.log(arr2);
console.log(arr2.splice(2,0,'google')); //并没有删除，也没添加
console.log(arr2);

//reverse
console.log(arr.reverse());

//sort
arr.push(5);
console.log(arr.sort());

// shift unshift
console.log('unshift shift');
arr.unshift(1,2);
console.log(arr);
console.log(arr.shift());



//push pop
console.log('->push pop');
var arr1=[1,2];
console.log(arr1.push('H')); //返回的是数组的长度
console.log(arr1.push('G'));
console.log(arr1.push('K'));
console.log(arr1.pop()); //返回的是pop出的元素
arr1.pop();
arr1.pop();
arr1.pop();
arr1.pop();
console.log(arr1.pop()); //没有元素可pop 则返回undefined


console.log('->indexOf');
//indexof()
console.log(arr.indexOf('A'))
console.log(arr.indexOf('a')); //没有找到则返回-1

console.log('->slice');
//array slice()
console.log(arr.slice(0,3)); //相当于java String的substring //返回截取的子数组  到3但是不包括3
console.log(arr.slice(3));
